package com.example.maggie.meizinote.di.module;

import com.example.maggie.meizinote.mvp.ui.adapter.NoteListAdapter;
import com.jess.arms.di.scope.ActivityScope;

import dagger.Module;
import dagger.Provides;

import com.example.maggie.meizinote.mvp.contract.SearchContract;
import com.example.maggie.meizinote.mvp.model.SearchModel;


@Module
public class SearchModule {
    private SearchContract.View view;
    private NoteListAdapter adapter;

    /**
     * 构建SearchModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
     *
     * @param view
     */
    public SearchModule(SearchContract.View view) {
        this.view = view;
    }

    @ActivityScope
    @Provides
    SearchContract.View provideSearchView() {
        return this.view;
    }

    @ActivityScope
    @Provides
    SearchContract.Model provideSearchModel(SearchModel model) {
        return model;
    }

    @ActivityScope
    @Provides
    NoteListAdapter provideNoteListAdapter() {
        if (adapter == null) adapter = new NoteListAdapter();
        return adapter;
    }

}